<template>
	<view class="chulizhong-box">
		<view v-if="leaveList.length==0" style="text-align: center;">
					<image src="../../static/nodata.png" class="nodata_img" ></image>
		</view>
		<view class="leave-content" @click="xiangqing(iterm.sno,iterm.name,iterm.leaveId)" v-for="(iterm,index) in leaveList" :key="index">
			<view class="leave-content-left">
				<view class="leave-content-left-top">
					<view class="leave-content-name zhengwen1">{{  iterm.name }}</view>
					<view class="leave-content-classnumber zhengwen1">学号：{{ iterm.sno }}</view>
				</view>
<!-- 				<view class="leave-content-time">
					<view class="leave-tiem zhengwen2">请假时间：（总时长{{iterm.hours}}小时）</view>
					<view class="leave-date zhengwen2">{{iterm.beginTime}}至{{iterm.endTime}}</view>
				</view> -->
				<view class="leave-content-time">
					<view class="leave-tiem">请假时间:&nbsp;&nbsp;(总时长{{iterm.hours}}小时)</view>
					<view class="leave-date">{{iterm.beginTime}}&nbsp;&nbsp;至&nbsp;&nbsp;{{iterm.endTime}}</view>
				</view>
			</view>
			<!-- <view class="leave-content-right"><view class="leave-content-right-box zhengwen1">{{iterm.status}}</view></view> -->
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			leaveList:[]
		};
	},
	created() {
		this.reloadRequest();
	},

	methods: {
		formatLeaveStatus(value) {
			switch (value) {
				case '1':
					return '请假中';
				case '2':
					return '已撤销';
				case '3':
					return '已销假';
				case '4':
					return '超时销假';
				default:
					return '未知状态';
			}
		},
		reloadRequest() {
			let _this = this;
			//请求首页数据
			uni.request({
				url: this.baseUrl + "/secretary/query/searchStatusList?satoken="+uni.getStorageSync('satoken'),
				method: 'GET',
				data: {
					current: 1,
					size: 10,
					status:['1']
				},
				withCredentials: true,
				headers: {
					//"content-type": "application/x-www-form-urlencoded",
					// token: localStorage.getItem('token')
				},
				success: res => {
					_this.leaveList = res.data.data.records;
					_this.leaveList = _this.leaveList.filter(iterm => {
						iterm.status = _this.formatLeaveStatus(iterm.status);
						return iterm.status;
					});
					
				}
			});
		},
		xiangqing(id,name,leaveId) {
			uni.navigateTo({
				url: '/pages/qingjiazhongDetails/qingjiazhongDetails?id='+id+'&name='+name+''+'&leaveId='+leaveId+''
			});
		}
	}
};
</script>

<style lang="scss">
@import url(@/static/common.css);
.chulizhong-box {
	width: 95%;
	margin: 0 auto;
	overflow: hidden;
	.leave-content {
		width: 100%;
		display: flex;
		box-sizing: border-box;
		background-color: #ffffff;
		flex-direction: row;
		align-items: center;
		margin-top: 30rpx;
		padding: 30rpx 0;
		padding-left: 20rpx;
		border-bottom: 1rpx solid #999999;
		.leave-content-left {
			flex: 2;
			display: flex;
			flex-direction: column;
			.leave-content-left-top {
				display: flex;
				flex-direction: row;
				// font-size: 28rpx;
				.leave-content-name {
					margin-right: 30rpx;
				}
			}
			.leave-content-time {
				// font-size: 24rpx;
				display: flex;
				flex-direction: column;
				margin-top: 20rpx;
				.leave-tiem {
					margin-bottom: 10rpx;
				}
				.leave-date {
					letter-spacing: 1rpx;
				}
			}
		}
		.leave-content-right {
			flex: 1;
			.leave-content-right-box {
				width: 200rpx;
				height: 100rpx;
				background-color: #f5f5f5;
				display: flex;
				align-items: center;
				justify-content: center;
				// font-size: 28rpx;
			}
		}
	}
}
</style>
